"""瑞华报文测试"""
import requests

base_url = 'http://10.41.6.15:8080/com.ifp.digitalbusiness/queryPolicyList'
params = f'userId=HJY8P26DN41O323A15786TS6086P4C'

headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.post(base_url, headers=headers, data=params)
print(response.content)

print(response.json())

data = {
    "plyDetail": {
        "applicant": {
            "CAppCde": "",
            "CAppNme": "纽带",
            "CCertfCls": "0",
            "CCertfCde": "611001198406065603",
            "CClntMrk": "0",
            "CMobile": "17621385669",
            "CCounty": "310101",
            "CProvince": "310000",
            "CCity": "310100",
            "CCountry": "",
            "CSuffixAddr": "",
            "CClntAddr": "咯哦微信我哦我",
            "CZipCde": "123123",
            "CEmail": "123@qq.com",
            "CWorkDpt": "",
            "CMrgCde": "",
            "CRelCde": "32",
            "CSex": "f",
            "TBirthday": "1984-06-06",
            "NAge": 33,
            "COccType": "00 ",
            "COccType2": "0001",
            "COccType3": "0001001",
            "CCusLvl": "1",
            "CCertfDateSign": "1",
            "CTaxCertfCde": "0",
        },
        "base": {
            "CAppTyp": "A",
            "CProdNo": "200001",
            "CProdNme": "爱加保医疗保险(实惠款)",
            "CDptCde": "99000000",
            "CSlsCde": "1",
            "CBsnsTyp": "1",
            "CBsnsSubtyp": "1",
            "CBrkrCde": "",
            "CAgtAgrNo": "",
            "NSubCoNo": "",
            "NDiscRate": 0.0,
            "CRenewMrk": "0",
            "CAmtCur": "01",
            "NAmt": 500000.0,
            "NAmtRmbExch": 1.0,
            "CPrmCur": "01",
            "NCalcPrm": 1000.0,
            "NPrm": 336.0,
            "NPrmRmbExch": 1.0,
            "TAppTm": 1508416379000,
            "TInsrncBgnTm": "2017-10-18 00:00:00",
            "TInsrncEndTm": "2018-10-18 00:00:00",
            "CGrpMrk": "0",
            "CInstMrk": "0",
            "COprCde": "900001649",
            "TOprTm": "2017-10-17 23:55:50",
            "CFinTyp": "0",
            "CSalegrpCde": "",
            "CSlsId": "",
            "CSlsNme": "",
            "CSlsTel": "",
            "CDataSrc": "02",
            "NPayTime": 106,
            "CPlanCde": "",
            "CLegalBnfc": "1",
            "CInsuYear": "1",
            "CInsuYearFlag": "1",
            "NPrmVar": 0.00,
            "NNoTaxPrm": 316.98,
            "NAddedTax": 19.02,
            "NBasePrm": "200",
            "CPayTimeFlag": "Y",
            "CTmplFlag": "0",
            "THsttPrd": "2017-10-28 00:00:00",
            "CPkgSts": "1",
            "CIsLineData": "1",
            "NPaymentDay": 1080,
            "NTimesPaid": "1",
            "TNextPayDate": "2021-02-28",
            "CIsRenewedFlag": "Y",
            "NTotalPayPrm": 644.8,
            "NPaidTime": 2,
            "CNoticeNo": "123",
            "NDssWtPrd": "5",
            "CPkgNo": "61700206907",
            "NHealthPrm": "",
            "NPkgPrm": "",
            "CFamilyFlag": "",
            "CHealthUpgradeFlag": "",
            "CDieDuty": "",
            "CServiceStatus": ""
        },
        "bnfcList": [
            {
                "CBnfcCde": "",
                "CBnfcNme": "猫猫",
                "CInsuredCde": "",
                "CRelCde": "31",
                "CBenfOrd": "1",
                "NBenfProp": 1,
                "CCertfCde": "611001198406065603",
                "CCertfCls": "0",
                "CSex": "f",
                "TBirthday": "1984-06-06",
                "CClntMrk": "1",
                "CMobile": "18012451245",
                "CSuffixAddr": "",
                "CCounty": "",
                "CCity": "",
                "CProvince": "",
                "CCountry": "",
                "CAddr": "纪录片可以在",
                "CZipCde": "123123",
                "CEmail": "",
                "CBnfcType": "2",
                "CCertfDateSign": "1"
            }
        ],
        "cvrgList": [
            {
                "CCvrgNo": "200100",
                "CCustCvrgNme": "一般医疗",
                "NAmt": 500000.0,
                "NBasePrm": 1000.0,
                "NPrm": 309.0,
                "CReMark": "",
                "CCancelMrk": "1",
                "TBgnTm": "2017-10-18 00:00:00",
                "TEndTm": "2018-10-18 00:00:00",
                "NNoTaxPrm": 291.51,
                "NTaxRate": 0.06,
                "NAddedTax": 17.49,
                "NDayAmt": ""
            },
            {
                "CCvrgNo": "200100",
                "CCustCvrgNme": "一般医疗",
                "NAmt": 500000.0,
                "NRate": 309.0,
                "NBasePrm": 1000.0,
                "NPrm": 309.0,
                "CReMark": "",
                "NIndemLmt": 0.0,
                "CCancelMrk": "1",
                "TBgnTm": "2017-10-18 00:00:00",
                "TEndTm": "2018-10-18 00:00:00",
                "NNoTaxPrm": 291.51,
                "NTaxRate": 0.06,
                "NAddedTax": 17.49
            },
            {
                "CCvrgNo": "200100",
                "CCustCvrgNme": "一般医疗",
                "NAmt": 500000.0,
                "NBasePrm": 1000.0,
                "NPrm": 309.0,
                "CReMark": "",
                "CCancelMrk": "1",
                "TBgnTm": "2017-10-18 00:00:00",
                "TEndTm": "2018-10-18 00:00:00",
                "NPrmVar": 0.00,
                "NNoTaxPrm": 291.51,
                "NTaxRate": 0.06,
                "NAddedTax": 17.49
            }
        ],
        "insuredList": [
            {
                "CInsuredCde": "",
                "CInsuredNme": "猫猫",
                "CInsuredCls": "0",
                "CRelInsuredCde": "",
                "CCertfCde": "611001198406065603",
                "CCertfCls": "0",
                "CClntMrk": "0",
                "CMobile": "18012451245",
                "CCountry": "",
                "CProvince": "610000",
                "CCity": "610100",
                "CCounty": "610101",
                "CSuffixAddr": "",
                "CClntAddr": "纪录片可以在",
                "CZipCde": "123123",
                "CEmail": "123@qq.cm",
                "CWorkDpt": "",
                "CWorkDptAddr": "",
                "CWorkDptZip": "",
                "CSex": "f",
                "TBirthday": "1984-06-06",
                "CMrgCde": "",
                "CChldStsCde": "",
                "NAge": 33.0,
                "CEduLvlCde": "",
                "CIsSoc": "1",
                "COccType": "00 ",
                "COccType2": "0001",
                "COccType3": "0001001",
                "CCusLvl": "1",
                "CCertfDateSign": "1",
                "NRevenue": 120000,
                "CTwoHealInformFlag": "Y"
            }
        ],
        "prodList": [
            {
                "CFinTyp": "12",
                "CInsuYear": "106",
                "CInsuYearFlag": "A",
                "CProdNo": "CT1001",
                "NPayTime": "20",
                "CPayTimeFlag": "Y",
                "CProdName": "瑞华个人医疗保险",
                "NAmount": 2000000.0,
                "NPrm": "282.0",
                "TInsrncBgnTm": "2018-08-31 00:00:00",
                "TInsrncEndTm": "2019-08-31 00:00:00"
            }
        ],
        "riskList": [
            {
                "CAppNo": "91810251083720",
                "CCrtCde": "Virtual",
                "CCvrgNo": "301002",
                "CEdrNo": "",
                "CLatestMrk": "1",
                "CPkId": "8a80813166ce57080166ce5729e90005",
                "CPkgNo": "61800516427",
                "CPlyNo": "111111111112",
                "CProdNo": "300002",
                "CReMark": "被保险人在等待期后初次罹患并经医院确诊为本合同定义的105种重大疾病，我们将按本合同基本保险金额给付重大疾病保险金，本合同终止。重大疾病确诊之后确诊的轻症疾病，我们不承担给付“轻症疾病保险金”的保险责任。同时确诊符合“重大疾病保险金”与“轻症疾病保险金”的给付条件，我们仅给付“重大疾病保险金”，本合同终止。重大疾病保险金的给付以一次为限。",
                "CRiskCls": "1",
                "CRiskNme": "重大疾病保险金",
                "CRiskNo": "30000101",
                "CRowId": "",
                "CType": "01",
                "CUnit": "元",
                "CUpdCde": "Virtual",
                "NAmt": "50000",
                "NEdrPrjNo": 0,
                "NSeqNo": 0,
                "TCrtTm": "2018-11-01 16:15:11",
                "TUpdTm": "2018-11-01 16:15:11"
            },
            {
                "CAppNo": "91810251083720",
                "CCrtCde": "Virtual",
                "CCvrgNo": "301002",
                "CEdrNo": "",
                "CLatestMrk": "1",
                "CPkId": "8a80813166ce57080166ce5729ea0006",
                "CPkgNo": "61800516427",
                "CPlyNo": "111111111112",
                "CProdNo": "300002",
                "CReMark": "首次轻症疾病保险金赔付30%的基本保额，该种轻症疾病的保险责任终止，合同继续有效；第2次轻症疾病保险金赔付35%的基本保额，该种轻症疾病的保险责任终止，合同继续有效；第3次轻症疾病保险金赔付40%的基本保额，该种轻症疾病的保险责任终止，此时轻症疾病保险金累积给付已达三次，轻症保险责任终止，重疾保险责任继续有效。同一轻症仅赔付1次，三次轻症保险金的赔付需要针对不同的轻症，且每次轻症需要在等待期后初次罹患并经医院确诊为本合同定义的55种轻症疾病。若被保险人因同一疾病原因或同一意外伤害事故导致其罹患本合同所定义的两种或两种以上的轻症疾病，我们仅按一种轻症疾病给付轻症疾病保险金。若我们已给付一次轻症疾病保险金，则本合同的现金价值自首次轻症疾病确诊之日起降低为零。",
                "CRiskCls": "1",
                "CRiskNme": "轻症疾病保险金",
                "CRiskNo": "30000105",
                "CRowId": "",
                "CType": "01",
                "CUnit": "元",
                "CUpdCde": "Virtual",
                "NAmt": "15000",
                "NEdrPrjNo": 0,
                "NSeqNo": 0,
                "TCrtTm": "2018-11-01 16:15:11",
                "TUpdTm": "2018-11-01 16:15:11"
            },
            {
                "CAppNo": "91810251083720",
                "CCrtCde": "Virtual",
                "CCvrgNo": "301002",
                "CEdrNo": "",
                "CLatestMrk": "1",
                "CPkId": "8a80813166ce57080166ce5729ea0007",
                "CPkgNo": "61800516427",
                "CPlyNo": "111111111112",
                "CProdNo": "300002",
                "CReMark": "被保险人在等待期后初次罹患并经医院确诊为本合同定义的轻症疾病，我们将豁免本合同的后续各期保险费，本项保险责任终止。被豁免的保险费视为已交纳，本合同继续有效，且本合同权益与正常交费的保险合同相同。",
                "CRiskCls": "1",
                "CRiskNme": "轻症疾病豁免保险费",
                "CRiskNo": "30000106",
                "CRowId": "",
                "CType": "01",
                "CUnit": "元",
                "CUpdCde": "Virtual",
                "NAmt": "豁免后期保险费",
                "NEdrPrjNo": 0,
                "NSeqNo": 0,
                "TCrtTm": "2018-11-01 16:15:11",
                "TUpdTm": "2018-11-01 16:15:11"
            }
        ],
        "accountInfoList": [
            {
                "CType": "SQ",
                "CBankCde": "104",
                "CAcctNme": "验证",
                "CAcctNo": "6216601152847617311"
            },
            {
                "CType": "XQ",
                "CBankCde": "BOC",
                "CAcctNme": "验证",
                "CAcctNo": "6216601152847617311"
            }
        ]
    },
    "status": "success"
}

status_ = data["status"]

if status_ == 'success':
    # 保单列表信息
    detail = data["plyDetail"]
    # 保单
    base = detail["base"]
    # 产品名称
    prod_nme = base["CProdNme"]
    # 保额
    amt = base["NAmt"]
    # 总保费
    prm = base["NPrm"]
    # 保险起期
    bgn_tm = base["TInsrncBgnTm"]
    # 保险止期
    end_tm = base["TInsrncEndTm"]

    # 险种信息
    risk_list = detail["riskList"]
    for risk in risk_list:
        policy_no = risk["CPlyNo"]
        risk_nme = risk["CRiskNme"]
        risk_amt = risk["NAmt"]
        risk_unit = risk["CUnit"]
else:
    print('没有查询到保单数据')
